package com.jspgou.cms.manager.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jspgou.cms.dao.BalanceDao;
import com.jspgou.cms.entity.Balance;
import com.jspgou.cms.manager.BalanceMng;
import com.jspgou.common.hibernate3.Updater;
import com.jspgou.common.page.Pagination;

@Service
@Transactional
public class BalanceMngImpl implements BalanceMng {
	@Transactional(readOnly = true)
	public Pagination getPage(int pageNo, int pageSize) {
		Pagination page = dao.getPage(pageNo, pageSize);
		return page;
	}
	
	@Transactional(readOnly = true)
	public Pagination getPage(Long storeId,String storeName,Date startTime,
			Date endTime,int pageNo, int pageSize) {
		Pagination page = dao.getPage(storeId,storeName,startTime,endTime,pageNo, pageSize);
		return page;
	}
	
	public List<Balance> getList(String storeName,Date startTime,Date endTime){
		List<Balance> list=dao.getList(storeName, startTime, endTime);
		return list;
	}


	@Transactional(readOnly = true)
	public Balance findById(Long id) {
		Balance entity = dao.findById(id);
		return entity;
	}

	public Balance save(Balance bean) {
		dao.save(bean);
		return bean;
	}

	public Balance update(Balance bean) {
		Updater<Balance> updater = new Updater<Balance>(bean);
		Balance entity = dao.updateByUpdater(updater);
		return entity;
	}

	public Balance deleteById(Long id) {
		Balance bean = dao.deleteById(id);
		return bean;
	}
	
	public Balance[] deleteByIds(Long[] ids) {
		Balance[] beans = new Balance[ids.length];
		for (int i = 0,len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

	private BalanceDao dao;

	@Autowired
	public void setDao(BalanceDao dao) {
		this.dao = dao;
	}
}